package org.hzz.api.code.controller;

import io.gitee.pkmer.convention.controller.BaseController;
import io.gitee.pkmer.convention.page.PageResponse;
import io.gitee.pkmer.convention.result.Result;
import lombok.Setter;
import org.hzz.api.code.ExchangeCodeApi;
import org.hzz.application.command.CodePageQueryCmd;
import org.hzz.application.service.PromotionsCmdService;
import org.hzz.promotions.types.req.ExchangeCodePageQuery;
import org.hzz.promotions.types.vo.ExchangeCodeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author <a href="mailto:1193094618@qq.com">pkmer</a>
 * <br>
 * <a href = "https://gitee.com/developeros/videos-online">Code Repository</a>
 * At 2024/9/1
 */
@RestController
public class ExchangeCodeController
        extends BaseController
        implements ExchangeCodeApi {

    @Setter(onMethod_ = @Autowired)
    private PromotionsCmdService cmdService;

    @Override
    public Result<PageResponse<ExchangeCodeVo>> pageQuery(ExchangeCodePageQuery pageQuery) {
        PageResponse<ExchangeCodeVo> pageResult = CodePageQueryCmd.commandOf(pageQuery)
                .executeWithResult(cmdService);
        return success(pageResult);
    }
}
